<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,initial-scale=1.0,width=device-width" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>添加案例</title>
    <link rel="stylesheet" type="text/css" href="../../../../css/aui/aui.css" />
    <link rel="stylesheet" type="text/css" href="../../../../css/html/issued/post_your_want_frm.css" />
    <style>

    </style>
</head>

<body>
    <div id="app">
        <div class="aui-content aui-margin-b-15">
            <ul class="aui-list aui-form-list" style="border-bottom:0.5rem solid #eee;">
                <li class="aui-list-item">
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-label">施工项目</div>
                        <div class="aui-list-item-input">
                            <input type="text" v-model="service.service_project" placeholder="请简述施工项目名称">
                        </div>
                    </div>
                </li>
                <li class="aui-list-item" @click="openCity()">
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-label">服务地点</div>
                        <div class="aui-list-item-input">
                            <input type="text" v-model="service.service_address" placeholder="请填写施工项目地点">
                        </div>
                    </div>
                </li>
                <li class="aui-list-item">
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-label">服务日期</div>
                        <div class="aui-list-item-input">
                            <input type="date" v-model="service.service_date" style="line-height:2.25rem;" placeholder="请填写服务日期">
                        </div>
                    </div>
                </li>
            </ul>

            <div class="aui-content-padded">
                <div style="margin:1rem 0 0.5rem 0;">上传图片<small style="font-size:0.5rem;color:#B7B7B7;">(最多可上传三张图，图片大小不要超过2MB)</small></div>
                <div class="up_image_box">
                    <div class="up_image" onclick="addImg(this,0)"><img src="../../../../image/icon/shangchuan.png" style="width:40%" alt=""></div>
                    <div class="up_image" onclick="addImg(this,1)"><img src="../../../../image/icon/shangchuan.png" style="width:40%" alt=""></div>
                    <div class="up_image" onclick="addImg(this,2)"><img src="../../../../image/icon/shangchuan.png" style="width:40%" alt=""></div>

                </div>
                <div class="btn" @click="addCase()">保存</div>
            </div>

        </div>
    </div>
</body>
<script src="../../../../script/api.js" charset="utf-8"></script>
<script src="../../../../script/aui/aui-tab.js" charset="utf-8"></script>
<script src="../../../../script/common/jquery-3.3.1.min.js" charset="utf-8"></script>
<script src="../../../../script/common/common.js" charset="utf-8"></script>
<script src="../../../../script/common/config.js" charset="utf-8"></script>
<script src="../../../../script/common/vue.min.js" charset="utf-8"></script>
<script>
    apiready = function() {
        api.parseTapmode();
        vm.init();

    }

    var vm = new Vue({
        el: "#app",
        data: {
            service: {
                service_project: '',
                service_address: '',
                service_date: '',
                service_image_array: []
            }
        },
        methods: {
            init() {

            },
            addCase() {
                var userInfo = get_local('userInfo');
                if (!is_define(this.service.service_project)) {
                    $toast("请简述施工项目名称");
                    return;
                } else if (!is_define(this.service.service_address)) {
                    $toast("请填写施工项目地点");
                    return;
                } else if (!is_define(this.service.service_date)) {
                    $toast("请填写服务日期");
                    return;
                }

                _ajax(Config.api.UserCaseCreate, {
                    user_id: userInfo.user_id,
                    service_project: this.service.service_project,
                    service_address: this.service.service_address,
                    service_date: this.service.service_date,
                    service_image_array: this.service.service_image_array
                }, function(ret) {
                    if (ret.code === 200) {
                        $toast("添加成功");
                        setTimeout(function() {
                            close_w();
                        }, 1000);
                    }
                });
            },
            openCity() {
                var url = '../../../city/city_win.html';
                api.openFrame({
                    name: 'mask',
                    url: url,
                    rect: {
                        x: 0,
                        y: api.winHeight - api.frameHeight,
                        w: 'auto',
                        h: 'auto'
                    },
                    bgColor: 'rgba(0,0,0,0.5)',
                    pageParam: {
                        name: api.winName,
                        frameName: api.frameName,
                    }
                });
            },

        }
    });

    function setCity(province, city, area) {
        vm.service.service_address = province.name + '-' + city.name + '-' + area.name
    }

    function addImg(e, i) {
        imageUpload(Config.api.ImageUploadcommon, function(ret) {
            $(e).find('img').attr('src', ret.data.imgurl).css({'width': '100%', 'height': '100%'});
            vm.service.service_image_array[i] = ret.data.imgurl;
        });
    }
</script>

</html>
